package com.yunxi.controller.sto;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import com.yunxi.sto.service.StoFrozenHisDubboService;
import com.yunxi.sto.pojo.StoFrozenHisVO;

/**
* <p>
* 车辆/库位冻结历史 前端控制器
* </p>
*
* @author caoyong
* @since 2019-10-11
*/
@RestController
@RequestMapping("/admin/stoFrozenHis")
@Api(tags = "sto:frozenHis", description = "车辆/库位冻结历史接口")
public class StoFrozenHisController {

    private static final Logger logger = LoggerFactory.getLogger(StoFrozenHisController.class);

    @Autowired
    StoFrozenHisDubboService stoFrozenHisDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询车辆/库位冻结历史分页")
        public ApiResult page(StoFrozenHisVO stoFrozenHisVO,Integer pageNum,Integer pageSize) throws Exception {
        return ResponseUtil.ok(stoFrozenHisDubboService.findPageByVO(stoFrozenHisVO,pageNum,pageSize));
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询车辆/库位冻结历史列表")
        public ApiResult list(StoFrozenHisVO stoFrozenHisVO) throws Exception {
        return ResponseUtil.ok(stoFrozenHisDubboService.listByVo(stoFrozenHisVO));
    }

    @GetMapping("/load")
    @ApiOperation(value = "读取单个车辆/库位冻结历史")
        public ApiResult load(StoFrozenHisVO stoFrozenHisVO, @CurrentUser LoginInfo loginInfo) throws Exception {
        return ResponseUtil.ok(stoFrozenHisDubboService.getById(stoFrozenHisVO.getFrozenHisId()));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存车辆/库位冻结历史信息")
    public ApiResult save(@RequestBody StoFrozenHisVO stoFrozenHisVO,@CurrentUser LoginInfo loginInfo) throws Exception {
        stoFrozenHisDubboService.saveOrUpdate(stoFrozenHisVO);
        return ResponseUtil.ok("success");
    }

    @PostMapping("/del")
    @ApiOperation(value = "删除车辆/库位冻结历史")
    public ApiResult del(@RequestBody List<StoFrozenHisVO> stoFrozenHisVOList) throws Exception {
        stoFrozenHisDubboService.removeByListVo(stoFrozenHisVOList);
        return ResponseUtil.ok("success");
    }

}
